package com.sz.service;

import com.sz.dao.IUserDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Service
public class VerfySVImpl implements IVerfySV{
    @Resource
    private IUserDao userDao;

    @Override
    public boolean isPwdTrue(String username, String password) {
        String pwd = userDao.getPwdByUn(username);
        if (pwd!=null && pwd.equals(password)) return true;
        else return false;
    }

    @Override
    public Map getNameAndAuth(String username) {
        Map nameAndAuth = userDao.getNameAndAuth(username);
        return nameAndAuth;
    }

    @Override
    public String isAuthTrue(int modauth, HttpServletRequest req) {
        int auth = (Integer) req.getSession().getAttribute("auth");
        if (modauth<auth){
            return "权限不足!";
        }else return "";
    }
}
